package com.soyotec.algorithm.algorithm.process;

import com.soyotec.algorithm.context.OptAlgorithmContext;

import java.io.BufferedWriter;
import java.io.File;
import java.io.RandomAccessFile;

public class AlgorithmRunnerWF extends AlgorithmRunner {
    private String tempFile;
    private RandomAccessFile raf;

    public String getTempFile() {
        return tempFile;
    }

    public AlgorithmRunnerWF(OptAlgorithmContext optAlgorithmContext){
        super(optAlgorithmContext);
        tempFile=optAlgorithmContext.getWorkDir().getAbsolutePath()+ File.separator+System.currentTimeMillis()+".temp";
    }
    @Override
    protected BufferedWriter createWriter(Process process) {
        try {
            raf=new RandomAccessFile(tempFile,"rw");
            RandomAccessFileWriter  randomAccessFileWriter=new RandomAccessFileWriter(raf);
            BufferedWriter bw=new BufferedWriter(randomAccessFileWriter);
            return bw;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }
}
